<%--
  Created by IntelliJ IDEA.
  User: 18042986105
  Date: 2021/6/12
  Time: 17:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style type="text/css">
        .layui-form{
            margin-right:200px;
            margin-top:50px;
            margin-left:40px;
        }
    </style>
</head>
<body>
<script src="../../layui/layui.js" charset="utf-8"></script>
<form class="layui-form" lay-filter="user-add-form"   enctype="multipart/form-data">

    <div class="layui-form-item">
        <label class="layui-form-label">选择分类</label>
        <div class="layui-input-block">
            <select name="types" lay-verify="required" class="sel">
                <option value=""></option>
                <option value="st">食堂</option>
                <option value="ss">宿舍</option>
                <option value="jx">教学楼</option>
                <option value="other">其它</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">文本域</label>
        <div class="layui-input-block">
            <textarea name="ggmessage" placeholder="请输入反馈" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-upload">
            选择图片: <input type="file" name="imgss" id="imgss"/> <br>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="forms" onclick="addFK()" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            // layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
    function addFK(){
        var formData = new FormData();

        formData.append('imgss', $('#imgss')[0].files[0]);
        formData.append('ggmessage',$('.layui-textarea').val());
        formData.append('types',$('.sel').val());

        $.ajax({
            url:'/normal/fk',
            data:formData,
            processData: false,
            contentType:false,
            dataType :"json",
            method: 'post',
            success: function (result) {
                console.log(result);
                alert('success');
                $('.layui-form')[0].reset();
            }
        })
    }

</script>


</body>
</html>
